import Vue from 'vue'
import App from './App.vue'
import VueRouter from 'vue-router'
import routes from './router/router.js' // 组件路由汇集文件
import store from './store'
import { routerMode } from './config/env'
import './config/rem'

Vue.use(VueRouter)
Vue.config.productionTip = false // 阻止显示生产模式的消息
const router = new VueRouter({
    routes, // 所有的组件路由
    mode: routerMode, // 路由模式
    strict: process.env.NODE_ENV !== 'production',
    scrollBehavior(to, from, savedPosition) {
        if (savedPosition) {
            return savedPosition
        } else {
            if (from.meta.keepAlive) {
                from.meta.savedPosition = document.body.scrollTop
            }
            return { x: 0, y: to.meta.savedPosition || 0 }
        }
    }
})

new Vue({
    router, // 注册路由实例
    store,
    render: h => h(App),
}).$mount('#app')
